home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Toolkit / Songbird 0.1 / Songbird_0_1_0.exe / components / sbIPlaylistPlayback.js < prev    next >
Text File  |  2006-02-07  |  6KB  |  236 lines

  1. /*
  2.  //
  3. // BEGIN SONGBIRD GPL
  4. // 
  5. // This file is part of the Songbird web player.
  6. //
  7. // Copyright⌐ 2006 Pioneers of the Inevitable LLC
  8. // http://songbirdnest.com
  9. // 
  10. // This file may be licensed under the terms of of the
  11. // GNU General Public License Version 2 (the ôGPLö).
  12. // 
  13. // Software distributed under the License is distributed 
  14. // on an ôAS ISö basis, WITHOUT WARRANTY OF ANY KIND, either 
  15. // express or implied. See the GPL for the specific language 
  16. // governing rights and limitations.
  17. //
  18. // You should have received a copy of the GPL along with this 
  19. // program. If not, go to http://www.gnu.org/licenses/gpl.html
  20. // or write to the Free Software Foundation, Inc., 
  21. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. // 
  23. // END SONGBIRD GPL
  24. //
  25.  */
  26.  
  27. //
  28. // sbIPlaylistPlayback Object
  29. //
  30.  
  31. const SONGBIRD_PLAYLISTPLAYBACK_CONTRACTID = "@songbird.org/Songbird/PlaylistPlayback;1";
  32. const SONGBIRD_PLAYLISTPLAYBACK_CLASSNAME = "Songbird PlaylistPlayback Interface"
  33. const SONGBIRD_PLAYLISTPLAYBACK_CID = Components.ID('{5D32F88B-D83F-42f9-BF6E-D56E833A78BA}');
  34. const SONGBIRD_PLAYLISTPLAYBACK_IID = Components.interfaces.sbIPlaylistPlayback;
  35.  
  36. function CPlaylistPlayback()
  37. {
  38.   jsLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
  39.   jsLoader.loadSubScript( "chrome://rmp_demo/content/songbird_interfaces.js", this );
  40.   jsLoader.loadSubScript( "chrome://rmp_demo/content/sbIDataRemote.js", this );
  41.  
  42.   this.m_queryObject = new this.sbIDatabaseQuery();
  43. }
  44.  
  45. /* I actually need a constructor in this case. */
  46. CPlaylistPlayback.prototype.constructor = CPlaylistPlayback;
  47.  
  48. /* the CPlaylistPlayback class def */
  49. CPlaylistPlayback.prototype = 
  50. {
  51.   m_Library: null,
  52.   m_PlaylistManager: null,
  53.   m_queryObject: null,
  54.   
  55.   m_strDBGUID: "",
  56.   m_strTable: "",
  57.  
  58.   m_strCurrentURL: "",
  59.   m_strCurrentGUID: null,
  60.  
  61.   m_bShuffle: false,
  62.   m_nRepeatMode: 0,
  63.   
  64.   Play: function(dbGUID, strTable, nStartPos)
  65.   {
  66.     this.m_queryObject.SetDatabaseGUID(dbGUID);
  67.     this.m_strDBGUID = dbGUID;
  68.     this.m_strTable = strTable;
  69.     
  70.     return true;
  71.   },
  72.   
  73.   PlayObject: function(playlistObj, nStartPos)
  74.   {
  75.     return false;
  76.   },
  77.   
  78.   Pause: function()
  79.   {
  80.   },
  81.   
  82.   Stop: function()
  83.   {
  84.   },
  85.   
  86.   Next: function()
  87.   {
  88.     return 0;
  89.   },
  90.     
  91.   Previous: function()
  92.   {
  93.     return 0;
  94.   },
  95.   
  96.   Current: function()
  97.   {
  98.     return 0;
  99.   },
  100.   
  101.   CurrentGUID: function()
  102.   {
  103.     return "";
  104.   },
  105.   
  106.   CurrentURL: function()
  107.   {
  108.     return this.m_strCurrentURL;
  109.   },
  110.   
  111.   Reset: function()
  112.   {
  113.     return false;
  114.   },
  115.  
  116.   SetRepeat: function(repeatMode)
  117.   {
  118.     if(repeatMode >= 0 && repeatMode <= 2)
  119.       this.m_nRepeatMode = repeatMode;
  120.   },
  121.   
  122.   GetRepeat: function()
  123.   {
  124.     return this.m_nRepeatMode;
  125.   },
  126.  
  127.   GetShuffle: function()
  128.   {
  129.     return this.m_bShuffle;
  130.   },
  131.   
  132.   SetShuffle: function(bShuffle)
  133.   {
  134.     this.m_bShuffle = bShuffle;
  135.     return;
  136.   },
  137.   
  138.   GetMetadataFields: function(nMetadataFieldCount)
  139.   {
  140.     nMetadataFieldCount = 0;
  141.     var aFields = new Array();
  142.     
  143.     return aFields;
  144.   },
  145.   
  146.   GetCurrentValue: function(strField)
  147.   {
  148.     return "";
  149.   },
  150.   
  151.   GetCurrentValues: function(nMetadataFieldCount, aMetaFields, nMetadataValueCount)
  152.   {
  153.     nMetadataValueCount = 0;
  154.     var aValues = new Array();
  155.     
  156.     return aValues;
  157.   },
  158.   
  159.   SetCurrentValue: function(strField, strValue)
  160.   {
  161.   },
  162.   
  163.   SetCurrentValues: function(nMetadataFieldCount, aMetaFields, nMetadataValueCount, aMetaValues)
  164.   {
  165.   },
  166.   
  167.   QueryInterface: function(iid)
  168.   {
  169.       if (!iid.equals(Components.interfaces.nsISupports) &&
  170.           !iid.equals(SONGBIRD_PLAYLISTPLAYBACK_IID))
  171.           throw Components.results.NS_ERROR_NO_INTERFACE;
  172.       return this;
  173.   }
  174. };
  175.  
  176. /**
  177.  * \class sbPlaylistPlaybackModule
  178.  * \brief 
  179.  */
  180. var sbPlaylistPlaybackModule = 
  181. {
  182.   registerSelf: function(compMgr, fileSpec, location, type)
  183.   {
  184.       compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  185.       compMgr.registerFactoryLocation(SONGBIRD_PLAYLISTPLAYBACK_CID, 
  186.                                       SONGBIRD_PLAYLISTPLAYBACK_CLASSNAME, 
  187.                                       SONGBIRD_PLAYLISTPLAYBACK_CONTRACTID, 
  188.                                       fileSpec, 
  189.                                       location,
  190.                                       type);
  191.   },
  192.  
  193.   getClassObject: function(compMgr, cid, iid) 
  194.   {
  195.       if (!cid.equals(SONGBIRD_PLAYLISTPLAYBACK_CID))
  196.           throw Components.results.NS_ERROR_NO_INTERFACE;
  197.  
  198.       if (!iid.equals(Components.interfaces.nsIFactory))
  199.           throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  200.  
  201.       return sbPlaylistPlaybackFactory;
  202.   },
  203.  
  204.   canUnload: function(compMgr)
  205.   { 
  206.     return true; 
  207.   }
  208. };
  209.  
  210. /**
  211.  * \class sbPlaylistPlaybackFactory
  212.  * \brief 
  213.  */
  214. var sbPlaylistPlaybackFactory =
  215. {
  216.     createInstance: function(outer, iid)
  217.     {
  218.         if (outer != null)
  219.             throw Components.results.NS_ERROR_NO_AGGREGATION;
  220.     
  221.         if (!iid.equals(SONGBIRD_PLAYLISTPLAYBACK_IID) &&
  222.             !iid.equals(Components.interfaces.nsISupports))
  223.             throw Components.results.NS_ERROR_INVALID_ARG;
  224.  
  225.         return (new CPlaylistPlayback()).QueryInterface(iid);
  226.     }
  227. }; //sbPlaylistPlaybackFactory
  228.  
  229. /**
  230.  * \function NSGetModule
  231.  * \brief 
  232.  */
  233. function NSGetModule(comMgr, fileSpec)
  234.   return sbPlaylistPlaybackModule;
  235. } //NSGetModule